package com.emip.bean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.emip.util.ReportFormat;

@Entity
@Table(name = "T_RealData")
public class RealDataBean implements Store, Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator="S_REALDATA_ID_GENE")
    @SequenceGenerator(name="S_REALDATA_ID_GENE",sequenceName="S_REALDATA_ID", allocationSize = 1)
	private int id;

	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "siteID")
	private SiteBean site;
	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "itemID")
	private ItemBean item;
	@Column(name="value")
	private String value;
	@Column(name="genTime")
	private Date genTime;	
	@Column(name="flag")
	private String flag;
	public RealDataBean() {
		
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getSiteID() {
		return site.getId();
	}
	public SiteBean getSite() {
		return site;
	}
	public void setSite(SiteBean site) {
		this.site = site;
	}
	public String getItemID() {
		return item.getId();
	}
	public ItemBean getItem() {
		return item;
	}
	public void setItem(ItemBean item) {
		this.item = item;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public Date getGenTime() {
		return genTime;
	}
	public void setGenTime(Date genTime) {
		this.genTime = genTime;
	}
	public String getFlag() {
		return flag;
	}
	public void setFlag(String flag) {
		this.flag = flag;
	}
	public String getTimeLabel() {
		return ReportFormat.getSecondFormat(genTime);
	}
}
